<?php
/**
 * Created by PhpStorm.
 * User: zeopean
 * Date: 2015/8/20
 * Time: 10:34
 */

namespace App\Exceptions;
use Exception;

class FocusException extends Exception{

    /**
     * NoAuthFocusProject           未登录，无法关注项目
     * NoProjectId                  无被关注的项目标识
     * NoAuthFocusInvestor          未登录，无法关注投资人
     * NoInvestorId                 无被关注投资人标识
     * NoAuthFocusInvestOrg         未登录，无法关注投资机构
     * NoInvestOrgId                无被关注的投资机构标识
     */
    const NoAuthFocusProject    = 0x01;
    const NoProjectId           = 0x02;
    const NoAuthFocusInvestor   = 0x03;
    const NoInvestorId          = 0x04;
    const NoAuthFocusInvestOrg  = 0x05;
    const NoInvestOrgId         = 0x06;

    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::NoAuthFocusProject:
                $message = trans('exception.focus_project.no_auth_focus_project');
                break;
            case self::NoProjectId:
                $message = trans('exception.focus_project.no_project_id' ,['project_id' => array_get($data, 'project_id')]);
                break;
            case self::NoAuthFocusInvestor:
                $message = trans('exception.focus_investor.no_auth_focus_investor');
                break;
            case self::NoInvestorId:
                $message = trans('exception.focus_investor.no_investor_id' ,['investor_id' => array_get($data, 'investor_id')]);
                break;
            case self::NoAuthFocusInvestOrg:
                $message = trans('exception.focus_invest_org.no_auth_invest_org');
                break;
            case self::NoInvestOrgId:
                $message = trans('exception.focus_invest_org.no_org_id' , ['org_id' => array_get($data , 'org_id')]);
                break;
            default:
                $message = trans('general.unknown_exception');
                break;
        }

        parent::__construct($message, $code, $previous);
    }

}
